package juc;

import java.util.concurrent.*;

public class MyThreadPool {
    public static void main(String[] args) {
        ExecutorService pool = new ThreadPoolExecutor(2,5,1l,TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(3), Executors.defaultThreadFactory(),new ThreadPoolExecutor.DiscardOldestPolicy());
        // 超过5+3队列数量，则会拒约
        for (int i = 0; i < 9; i++) {
            pool.execute(()->{
                System.out.println(Thread.currentThread().getName());
            });
        }
        pool.shutdown();
    }
}
